package nl.nickthissen.remindme.data;

import com.activeandroid.Model;
import com.activeandroid.query.Select;

import java.util.ArrayList;

import nl.nickthissen.remindme.common.CategoryColors;

/**
 * Created by nthissen on 11/06/13.
 */
public class CategoryManager
{
    public static void initialize()
    {
        categories = new Select().from(Category.class).execute();
        defaultCategory = createDefaultCategory();
    }

    public static ArrayList<Category> categories;

    private static Category defaultCategory;
    public static Category getDefaultCategory()
    {
        return defaultCategory;
    }

    private static Category createDefaultCategory()
    {
        Category cat = new Select().from(Category.class).where("IsDefault=?", 1).executeSingle();
        if (cat != null) return cat;

        cat = new Category();
        cat.name = "Default category";
        cat.description = "";
        cat.color = CategoryColors.getDefaultColor();
        cat.isDefault = 1;
        cat.save();
        return cat;
    }
}
